<extend name="public/base" />
<extend name="public/xbase"/>
<block name="style">
	<link rel="stylesheet" href="__PUBLIC__/admin/js/codemirror/codemirror.css">
	<link rel="stylesheet" href="__PUBLIC__/admin/js/codemirror/theme/{:C('codemirror_theme')}.css">
	<style>
		.CodeMirror,#preview_window{
			width:100%;
			height:500px;
		}
	</style>
</block>
<block name="body">
<div class="layui-card qn-header">
	<div class="layui-breadcrumb">
		<a href="">首页</a>
		<a href=""><cite>编辑主题【{$theme}】 - 当前路径：<label for="content">{$Think.FRONT_THEME_PATH}{$theme}/{$file|base64_decode}</label></cite></a>
	</div>
</div>
<div class="layui-fluid">
	<div class="layui-card">
		<div class="layui-card-body">
		
<div class="row">
	<div class="col-lg-12">
		<div class="widget-container fluid-height">
			<div class="widget-content padded">
				<form action="{:U('save')}" id="theme" name="theme" method="post" class="form-horizontal">
				<div class="form-group" style="margin-left:0; margin-right:0">
						<label class="sr-only" for="content">编辑源码</label>
						<textarea class="w-100 mono" id="content" name="content">{$content}</textarea>
				</div>
				<div class="form-group" style="margin-left:0; margin-right:0">
					<div class="controls">
							<input type="hidden" name="file" id="file" value="{$file|default=''}">
							<input type="hidden" name="name" id="name"  value="{$theme}">
							<div class="btn btn-primary" id="tsubmit">保存文件</div>
							<button target-form="form-horizontal" class="btn submit-btn ajax-post" type="submit" id="submit" style="display:none">保存文件</button>
							<a class="btn btn-default-outline" href="{:U('index')}">返回主题列表</a>
					</div>
				</div>
				</form>
				<div class="form-group">
					模版文件
				</div>
				<div class="form-group">
					<select class="form-control" multiple="">
					<volist name="list" id="vo">
						<option value="" onclick="window.location.href='{:U('Theme/edit',array('name'=>$theme, 'file'=>base64_encode($vo)))}'">{$vo}</option>					
					</volist>
					</select>
				</div>
			</div>
		</div>
	</div>
</div>
</div>
</div>
</div>
</block>

<block name="script">
<script type="text/javascript" src="__PUBLIC__/admin/js/codemirror/codemirror.js"></script>
<script type="text/javascript" src="__PUBLIC__/admin/js/codemirror/xml.js"></script>
<script type="text/javascript" src="__PUBLIC__/admin/js/codemirror/javascript.js"></script>
<script type="text/javascript" src="__PUBLIC__/admin/js/codemirror/htmlmixed.js"></script>
<script type="text/javascript" src="__PUBLIC__/admin/js/codemirror/htmlembedded.js"></script>
	 <script>
			var codemirror_option = {
							lineNumbers   :true,
							matchBrackets :true,
							mode          :"application/x-httpd-php",
							indentUnit    :4,
							gutter        :true,
							fixedGutter   :true,
							indentWithTabs:true,
							readOnly	  :false,
							lineWrapping  :true,
							height		  :500,
							enterMode     :"keep",
							tabMode       :"shift",
							theme: "{:C('CODEMIRROR_THEME')}"
						};
      var editor = CodeMirror.fromTextArea(document.getElementById("content"), {
        lineNumbers: true,
       // mode          :"application/x-httpd-php",
		mode:"application/x-ejs",
        indentUnit: 4,
        indentWithTabs: true,
		theme: "{:C('CODEMIRROR_THEME')}"
      });
	//  alert(editor.getValue());
	  $("#tsubmit").click(function(){
		$("#content").val(editor.getValue());
		$("#submit").click();
		});
    </script>
</block>
